<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('作业列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>课程名称：</label>
                                <select name="courseName" th:with="type=${@dict.getType('s_course_name')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>作业标题：</label>
                                <input type="text" name="title"/>
                            </li>
<!--                            <li>-->
<!--                                <label>开始时间：</label>-->
<!--                                <input type="text" class="time-input" placeholder="请选择开始时间" name="startTime"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>截止时间：</label>-->
<!--                                <input type="text" class="time-input" placeholder="请选择截止时间" name="endTime"/>-->
<!--                            </li>-->
                            <li>
                                <label>作业状态：</label>
                                <select name="status" th:with="type=${@dict.getType('s_homework_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="homework:leavehomework:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="homework:leavehomework:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="homework:leavehomework:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="homework:leavehomework:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var submitFlag = [[${@permission.hasPermi('homework:leavehomework:dohomework')}]];
        var infoFlag = [[${@permission.hasPermi('homework:leavehomework:homeworkinfo')}]];
        var editFlag = [[${@permission.hasPermi('homework:leavehomework:edit')}]];
        var removeFlag = [[${@permission.hasPermi('homework:leavehomework:remove')}]];
        var detailFlag = [[${@permission.hasPermi('homework:Stuhomework:detail')}]];
        var courseNameDatas = [[${@dict.getType('s_course_name')}]];
        var statusDatas = [[${@dict.getType('s_homework_status')}]];
        var prefix = ctx + "homework/leavehomework";
        var sprefix = ctx +"homework/Stuhomework";//作业路径

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                hsubmiteUrl: sprefix + "/hsubmit",//作业路径
                infoUrl: sprefix + "/Stuhomework",//作业路径
                detailUrl: prefix + "/detail/{id}",//作业详情
                modalName: "作业",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'ID',
                    visible: true
                },
                // {
                //     field: 'teacherId',
                //     title: '教师id'
                // },
                {
                    field: 'teacherName',
                    title: '教师姓名'
                },
                {
                    field: 'courseName',
                    title: '课程名称',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(courseNameDatas, value);
                    }
                },
                {
                    field: 'title',
                    title: '作业标题'
                },
                // {
                //     field: 'content',
                //     title: '作业内容'
                // },
                {
                    field: 'startTime',
                    title: '开始时间',
                    formatter: function(value, row, index) {
                        return $.common.dateFormat(value, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                {
                    field: 'endTime',
                    title: '截止时间',
                    formatter: function(value, row, index) {
                        return $.common.dateFormat(value, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                {
                    field: 'remark',
                    title: '备注信息'
                },
                {
                    field: 'status',
                    title: '作业状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + submitFlag + '" href="javascript:void(0)" onclick="doHomework(\'' + row.id + '\')"><i class="fa fa-search"></i>写作业</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + infoFlag + '" href="javascript:void(0)" onclick="Homeworkinfo(\'' + row.id + '\')"><i class="fa fa-search"></i>作业情况</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-search"></i>详情</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        //跳转到写作业页面
        function doHomework(homeworkId) {
            var url = sprefix + '/add/' + homeworkId;
            $.modal.open("写作业", url,"1000","700");
            // $.modal.openTab("写作业", url);
        }
        //跳转到作业情况页面
        function Homeworkinfo(){
            var url = sprefix;
            $.modal.openTab("作业情况",url);
        }
    </script>
</body>
</html>